﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Brc_PaaS.Api.Common;
using Brc_PaaS.Bll.Apollo;
using Brc_PaaS.Bll.System;
using Brc_PaaS.Common.Model.Basic;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;

namespace Brc_PaaS.Api.Controllers
{
    /// <summary>
    /// 配置信息
    /// </summary>
    [Route("api/config/[controller]/")]
    [ApiController]
    [EnableCors("any")]
    [ApiExplorerSettings(GroupName = "Config")]
    public class ConfigController : ConfigBaseController
    {

        private readonly IApollo apolloService;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="system"></param>
        /// <param name="apolloService"></param>
        public ConfigController(IConfiguration configuration,  ISystem system,IApollo apolloService) : base(configuration, apolloService, system)
        {
            this.apolloService = apolloService;
        }

        /// <summary>
        /// 获取配置
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        [HttpGet]
        
        public  ActionResult<ResponseModel<string>> GetConfig(string key)
        {
            var result =apolloService.GetConfig(key, SystemInfo,ApolloInfo);
            return Ok(result);
        }

        
    }
}